package com.zhiyizhen.callnumber.net;

import com.zhiyizhen.callnumber.net.response.ResponseData;

import java.io.IOException;
import java.io.Serial;

public class ResponseException extends IOException {

    @Serial
    private static final long serialVersionUID = -460533980517855163L;

    private final String code;
    private final String msg;
    private transient ResponseData<?> responseData;

    public ResponseException() {
        this("-1", "网络错误！");
    }

    public ResponseException(ResponseData<?> responseData) {
        this(responseData.getCode(), responseData.getMsg());
        this.responseData = responseData;
    }

    public ResponseException(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public ResponseData<?> getResponseData() {
        return responseData;
    }
}
